//
//  YFMomentApi.m
//  SquashSpark
//
//  Created by Coollang on 2017/11/22.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFMomentApi.h"
#import "NSString+Extension.h"

@implementation YFMomentApi

// 发帖
+ (instancetype)postTopicApiWithPosition:(NSString *)postion content:(NSString *)text imgList:(NSArray *)imgList {
    NSDictionary *dict = @{
                           @"position":[NSString checkIfNullWithString:postion],
                           @"subject":@"subject-iOS_BiQiu",
                           @"text":[NSString checkIfNullWithString:text],
                           @"imgList":(imgList != nil ? imgList:@[]),
                           };
    
    YFMomentApi *api = [YFMomentApi requestApiWithType:kMomentsPostTopic andParam:dict];
    return api;
}

/**
 *  获取帖子列表
 *  from  1为关注,0为广场全部
 */
+ (instancetype)getTopicListApiWithPage:(NSUInteger)page from:(NSString *)from {
    
    NSDictionary *dict = @{
                           @"page":@(page).stringValue,
                           @"from":[NSString checkIfNullWithString:from],
                           };
    YFMomentApi *api = [YFMomentApi requestApiWithType:kMomentsGetTopicList andParam:dict];
    return api;
}

/**
 *  评论回复
 *  parentID  如果是回复他人的评论,则需要加这个字段
 */
+ (instancetype)commentOrResponseApiWithText:(NSString *)text postId:(NSString *)postId parentID:(NSString *)parentID {
    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{
                                                    @"text":[NSString checkIfNullWithString:text],
                                                    @"postID":[NSString checkIfNullWithString:postId],
                                                    }];
    if (parentID.length > 0) {
        [dict setObject:parentID forKey:@"parentID"];
    }
    YFMomentApi *api = [YFMomentApi requestApiWithType:kMomentPostCommentResponse andParam:dict.copy];
    return api;
}

/**
 *  帖子模块，只需传帖子id
 *  点赞，取消点赞， 删除帖子
 */
+ (instancetype)mommentNormalApiWithApiType:(RequestApiType)apiType postId:(NSString *)postId {
    YFMomentApi *api = [YFMomentApi requestApiWithType:apiType andParam:@{@"postID":[NSString checkIfNullWithString:postId]}];
    return api;
}

/**
 *  删除评论
 */
+ (instancetype)deleteCommentApiWithReponseId:(NSString *)responseId {
    YFMomentApi *api = [YFMomentApi requestApiWithType:kMomentsDeleteComment andParam:@{@"responseID":[NSString checkIfNullWithString:responseId]}];
    return api;
}
// 举报
+ (instancetype)spotterTopicApiWithPostId:(NSString *)postId userId:(NSString *)userId type:(SpotterTopicType)spotterType {
    NSDictionary *dict = @{
                           @"postId":[NSString checkIfNullWithString:postId],
                           @"userID":[NSString checkIfNullWithString:userId],
                           @"type":@(spotterType).stringValue,
                           };
    YFMomentApi *api = [YFMomentApi requestApiWithType:kMomentsSpotterTopic andParam:dict];
    return api;
}

// 消息相关的接口
+ (instancetype)messageApiWithApiType:(RequestApiType)apiType argument:(id)argument {
     YFMomentApi *api = [YFMomentApi requestApiWithType:apiType andParam:argument];
    return api;
}

@end
